<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        //根据要求生成对应的数据结构
        let str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

        let cites = [
            { py: 'beijing', name: '北京' },
            { py: 'alishan', name: '阿里山' },
            { py: 'beidaihe', name: '北戴河' },
            { py: 'shijiazhuang', name: '石家庄' },
            { py: 'riben', name: '热本' }
        ]

        /*
            let datas = {
                    A:[],
                    B:[],
                    C:[],
                    ...
                }
        */
        let datas = {}
        let source1 = Object.values(str);

        source1.forEach(function (item) {
            datas[item] = [];
        });
        for (var index in cites) {
            source1.forEach(function (item, array) {
                if (cites[index].py.toUpperCase().startsWith(item)) {
                    datas[item].push(cites[index])
                }
            });
        }
        console.log(datas);
    </script>
</body>

</html>